Imports System.Xml

Partial Class Secure_Reports_Report
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim strReportName As String = Request.QueryString("reportName")
            If Not String.IsNullOrEmpty(strReportName) Then
                Dim myXML As XmlDocument = xdsReportDef.GetXmlDocument
                Dim myNode As XmlNode = myXML.SelectSingleNode("/reportList/reportGroup/report[@fileName='" & strReportName & "']")
                Dim dataSourceType As String = myNode.Attributes("dataSourceType").Value
                Dim dataSourceName As String = myNode.Attributes("dataSourceName").Value
                rViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local
                rViewer.LocalReport.ReportPath = "Secure\Reports\" & strReportName
                'Response.Write(rViewer.LocalReport.GetDefaultPageSettings.PaperSize.Kind.ToString)

                Select Case dataSourceType
                    Case "DataSet"
                        Dim ds As New ObjectDataSource("dsReportTableAdapters." & dataSourceName & "TableAdapter", "GetData")
                        rViewer.LocalReport.DataSources.Add( _
                            New Microsoft.Reporting.WebForms.ReportDataSource("dsReport_" & dataSourceName, ds))
                        rViewer.LocalReport.Refresh()
                    Case "ODS"
                        Dim ds As New ObjectDataSource("DotNetPM.Business.Questionnaire.ReportODS", "GetQuestionnaireAnswer")
                        ds.SelectParameters.Add(New Parameter("QuestionnaireID", TypeCode.Int32, "1"))
                        rViewer.LocalReport.DataSources.Add( _
                            New Microsoft.Reporting.WebForms.ReportDataSource("GetQuestionnaireAnswer", ds))
                        rViewer.LocalReport.Refresh()

                End Select
            End If
            rViewer.Height = New Unit(800, UnitType.Pixel)

        End If
    End Sub
End Class
